# vPresent is an immersive presentation creation and display application.
# Copyright (C) 2007-2009 by Priority 5 Holdings, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'vpresent/aboutui.ui'
#
# WARNING! All changes made in this file will be lost!

import os 
import Ft 
from Ft.Xml import Parse 
from xml.dom import Node 
import gui.util 

class UiManager(object):
   def __init__(self, fileName = None):
      if (fileName is None):
         fileName = os.path.join(gui.util.const.DATA_DIR, 'ribbon.xml')
      uri = Ft.Lib.Uri.OsPathToUri(fileName)
      doc = Parse(uri)
      root = doc.childNodes[0]
      assert (root.localName == 'ribbon')
      self.mTabs = {}
      tab_nodes = [ t for t in root.childNodes if (t.nodeType != Node.TEXT_NODE) ]
      for tab in tab_nodes:
         assert (tab.localName == 'tab')
         group_nodes = [ g for g in tab.childNodes if (g.nodeType != Node.TEXT_NODE) ]
         groups = []
         for g in group_nodes:
            assert (g.localName == 'group')
            groups.append((g.getAttributeNS(None, 'title'),
                           g.getAttributeNS(None, 'class'),
                           g.getAttributeNS(None, 'spacing')))

         self.mTabs[tab.getAttributeNS(None, 'object-type')] = groups
